require('@assets/css/main.css')
const {
	$U_GetItem,
	$U_UserInfo,
	$U_LocalUserInfo,
} = require('@utils/storage')

const init = {
	// 初始化菜单栏
	west: require('./main-tree'),
	center: require('./main-tabs'),
}

module.exports = function() {
	let userInfo = $U_UserInfo()
	if (!userInfo || !userInfo.id || !userInfo.account || !userInfo.password) {
		$.spaRouters.next('index')
		return false
	}
	let {
		mainComp,
	} = $['components-jq']
	let layoutJQ = mainComp.layoutJQ = $("#main-layout")
	layoutJQ.layout({
		fit: true,
		onAdd(region) {
			if (typeof init[region] == 'function')
				init[region]()
		}
	}).layout('add', {
		region: 'west',
		width: 120,
		title: 'West Title',
		split: true,
		content: '<div id="main-tree"></div>',
	}).layout('add', {
		region: 'center',
		title: 'Center Title',
		content: '<div id="main-tabs"></div>',
	}).layout('resize').layout('collapse', 'west')
}